package com.ruoyi.web.controller.data;

import com.ruoyi.bus.service.IDataService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/dataSystem")
public class SystemDataController {

    @Autowired
    private IDataService dataService;

    @GetMapping("getData")
    public AjaxResult getData(){
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("routeCount", this.getRouteCount());
        paramMap.put("busCount", this.getBusCount());
        paramMap.put("driverCount", this.getDriverCount());
        paramMap.put("userCount", this.getUserCount());
        return AjaxResult.success(paramMap);
    }

    @GetMapping("listAppointByDays")
    public AjaxResult listAppointByDays(@RequestParam Integer day){
        return AjaxResult.success(dataService.listAppointByDays(day));
    }

    /**
     * @Description 按日期分类查最近七天的已排班路线数据
     * @Author caiyanshan
     * @Date 2021/6/7 14:42
     * @Param []
     * @Return com.ruoyi.common.core.domain.AjaxResult
     */
    @GetMapping("listRouteByDays")
    public AjaxResult listRouteByDays(@RequestParam Integer day){
        return AjaxResult.success(dataService.listRouteByDays(day));
    }

    @GetMapping("listPlanByDays")
    public AjaxResult listPlanByDays(@RequestParam Integer day){
        return AjaxResult.success(dataService.listPlanByDays(day));
    }

    @GetMapping("listSecondDeptByUsers")
    public AjaxResult listSecondDeptByUsers(){
        return AjaxResult.success(dataService.listSecondDeptByUsers());
    }

    public int getRouteCount(){
        return dataService.getRouteCount();
    }

    public int getDriverCount(){
        return dataService.getDriverCount();
    }

    public int getUserCount(){
        return dataService.getUserCount();
    }

    public int getBusCount(){
        return dataService.getBusCount();
    }

}
